﻿using FreestyleCoding.CardLib;

namespace CardRoulette {
	public enum DeckColors {
		Red,
		Black
	}

	public enum DeckRanges {
		Low,	// Ace through 5
		Mid,	// 6, 7 aor 8
		High	// 9 through King
	}

	public static class Odds {
		public static float SuitBet( Suits p_Suit ) {
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				if( _Card.Suit == p_Suit )
					_Count += Statistics.m_CardDictionary[_Card];
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}

		public static float JokerBet( DeckColors p_Color ) {
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker ) {
					switch( p_Color ) {
						case DeckColors.Black:
							if( ( _Card.Suit == Suits.Clubs ) || ( _Card.Suit == Suits.Spades ) )
								_Count += Statistics.m_CardDictionary[_Card];
							break;
						case DeckColors.Red:
							if( ( _Card.Suit == Suits.Diamonds ) || ( _Card.Suit == Suits.Hearts ) )
								_Count += Statistics.m_CardDictionary[_Card];
							break;
					}
				}
			}

			return _Count / ( System.Convert.ToSingle( Statistics.m_CardCount ) + System.Convert.ToSingle( Statistics.m_JokerCount ) );
		}

		public static float ColorBet( DeckColors p_Color ) {
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				switch( p_Color ) {
					case DeckColors.Black:
						if( ( _Card.Suit == Suits.Clubs ) || ( _Card.Suit == Suits.Spades ) )
							_Count += Statistics.m_CardDictionary[_Card];
						break;
					case DeckColors.Red:
						if( ( _Card.Suit == Suits.Diamonds ) || ( _Card.Suit == Suits.Hearts ) )
							_Count += Statistics.m_CardDictionary[_Card];
						break;
				}
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}

		public static float RangeBet( DeckRanges p_Range ) {
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				switch( p_Range ) {
					case DeckRanges.Low:
						if( ( _Card.Rank == Ranks.Ace ) || ( _Card.Rank == Ranks.Two ) || ( _Card.Rank == Ranks.Three ) || ( _Card.Rank == Ranks.Four ) || ( _Card.Rank == Ranks.Five ) )
							_Count += Statistics.m_CardDictionary[_Card];
						break;
					case DeckRanges.Mid:
						if( ( _Card.Rank == Ranks.Six ) || ( _Card.Rank == Ranks.Seven ) || ( _Card.Rank == Ranks.Eight ) )
							_Count += Statistics.m_CardDictionary[_Card];
						break;
					case DeckRanges.High:
						if( ( _Card.Rank == Ranks.Nine ) || ( _Card.Rank == Ranks.Ten ) || ( _Card.Rank == Ranks.Jack ) || ( _Card.Rank == Ranks.Queen ) || ( _Card.Rank == Ranks.King ) )
							_Count += Statistics.m_CardDictionary[_Card];
						break;
				}
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}

		public static float OneCardBet( IPlayingCard p_Card ) {
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				if( _Card == p_Card )
					_Count += Statistics.m_CardDictionary[_Card];
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}

		public static float TwoCardBet( IPlayingCard p_Card1, IPlayingCard p_Card2 ) {
			// I really should check that the two card cells are touching...
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				if( ( _Card == p_Card1 ) || ( _Card == p_Card2 ) )
					_Count += Statistics.m_CardDictionary[_Card];
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}

		public static float FourCardBet( IPlayingCard p_Card1, IPlayingCard p_Card2, IPlayingCard p_Card3, IPlayingCard p_Card4 ) {
			// I really should check that the four card cells are touching...
			float _Count = 0f;

			foreach( IPlayingCard _Card in Statistics.m_CardDictionary.Keys ) {
				if( _Card.Rank == Ranks.Joker )
					continue;

				if( ( _Card == p_Card1 ) || ( _Card == p_Card2 ) || ( _Card == p_Card3 ) || ( _Card == p_Card4 ) )
					_Count += Statistics.m_CardDictionary[_Card];
			}

			return _Count / System.Convert.ToSingle( Statistics.m_CardCount );
		}
	}
}